package com.decent.entity;

import com.decent.constant.Constant;
import com.decent.util.Md5Util;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @Author decent
 * @Create 2021/3/31 - 13:56
 * @Description
 */
@Data
@Component
//@ConfigurationProperties(prefix = "application")
//@PropertySource(value = {"classpath:application.properties"})
public class GetOrderEntity {
//    @Value("${getOrder.supId}")
    private Integer supId;

//    @Value("${getOrder.amount}")
    private Integer amount;

    private String timestamp;

    private String sign;

//    @Value("${getOrder.url}")
    private String url;

//    @Value("${getOrder.supIdSecretKey}")
    private String supIdSecretKey;

    public GetOrderEntity() {
        this.supId = 10005;
        this.amount = 1;
        this.url = Constant.GET_ORDER;
        this.supIdSecretKey = Constant.SUP_SECRET_KEY;
        this.timestamp = System.currentTimeMillis() + "";
        this.sign = Md5Util.getMD5(supId, amount, timestamp, supIdSecretKey);
    }

    public GetOrderEntity(Integer supId, Integer amount, String timestamp) {
        this.supId = supId;
        this.amount = amount;
        this.timestamp = timestamp;
//        this.sign = supId + "" + amount + "" + timestamp + "" + Constant.SUP_SECRET_KEY;
        this.sign = Md5Util.getMD5(supId, amount, timestamp, supIdSecretKey);
    }
}
